<ui:composition template="/pages/workspace_page.xhtml"
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:c="http://java.sun.com/jstl/core"
  xmlns:a4j="http://richfaces.org/a4j"
  xmlns:nxd="http://nuxeo.org/nxweb/document"
  xmlns:nxl="http://nuxeo.org/nxforms/layout"
  xmlns:nxh="http://nuxeo.org/nxweb/html"
  xmlns:nxu="http://nuxeo.org/nxweb/util">

  <ui:define name="page title">
    <h:outputText value="#{nuxeoApplicationName} - #{nxd:titleOrId(currentDocument)}"/>
  </ui:define>

  <ui:define name="bookmark">
    <link rel="bookmark" href="#{navigationContext.currentDocumentFullUrl}"/>
  </ui:define>

  <ui:define name="body">
    <div>

      <h:form id="document_header_layout_form" class="titleBlock">
        <nxl:documentLayout mode="header" value="#{currentDocument}"
          defaultLayout="document_header" includeAnyMode="false" />
      </h:form>

     <div class="exportViewBrowseBack">
        <p class="action_bar directoryBack">
          <nxd:restDocumentLink document="#{currentDocument}">
            <nxh:graphicImage value="/icons/arrow_left.gif" />
            <h:outputText value="#{messages['label.browse.backToDocumentView']}" />
          </nxd:restDocumentLink>
        </p>
      </div>

      <ui:include src="/incl/message_banner.xhtml"/>

      <div class="tabsBar">
        <ul>
          <li class="selected">
            <nxd:restDocumentLink document="#{currentDocument}" view="export">
              <h:outputText value="#{messages['label.exportview']}" />
            </nxd:restDocumentLink>
          </li>
        </ul>
      </div>
      <div style="clear:both"></div>
      <div class="tabsContent">

        <nxu:set var="exportActions"
          value="#{webActions.getActionsList('DOCUMENT_EXPORT_VIEW_ACTION')}"
          cache="true">
        <nxu:set var="exportCommandActions"
          value="#{webActions.getActionsList('DOCUMENT_EXPORT_VIEW_COMMAND_ACTION')}"
          cache="true">
          <c:if test="#{not empty exportActions or not empty exportCommandActions}">
            <h2>#{messages['label.exportview.document']}</h2>
            <c:forEach var="action" items="#{exportActions}">
                <nxu:set var="tooltipMessage"
                  value="#{action.label}.tooltip">
                  <nxh:metaOutputLink value="#{action.getLink()}"
                    target="_blank" title="#{messages[tooltipMessage]}"
                    styleClass="tipsyShow">
                    <h:graphicImage value="#{action.icon}"
                      rendered="#{not empty action.icon}" />
                    <h:outputText value=" #{messages[action.label]}" />
                  </nxh:metaOutputLink>
                </nxu:set>
                <br />
            </c:forEach>
            <h:form>
              <c:forEach var="action" items="#{exportCommandActions}">
                  <nxu:set var="tooltipMessage"
                    value="#{action.label}.tooltip">
                    <nxh:commandLink action="#{action.getLink()}"
                      immediate="#{action.immediate}"
                      onclick="#{action.confirm}"
                      title="#{messages[tooltipMessage]}"
                      styleClass="tipsyShow">
                      <h:graphicImage value="#{action.icon}"
                        rendered="#{not empty action.icon}" />
                      <h:outputText value=" #{messages[action.label]}" />
                    </nxh:commandLink>
                  </nxu:set>
                  <br />
              </c:forEach>
            </h:form>
          </c:if>
        </nxu:set>
        </nxu:set>

        <br />

        <nxu:set var="exportContentViews"
          value="#{documentContentViewActions.getExportContentViewsForCurrentDocument()}"
          cache="true">
          <c:if test="#{not empty exportContentViews}">
            <h2>#{messages['label.exportview.contentviews']}</h2>
            <c:forEach var="contentViewByCategory"
              items="#{documentContentViewActions.getExportContentViewsForCurrentDocument()}">
              <c:forEach var="contentViewHeader"
                items="#{contentViewByCategory.value}">

                <nxu:set var="contentView"
                  value="#{contentViewActions.getContentViewWithProvider(contentViewHeader.name)}"
                  cache="true">

                  <c:set var="contentViewTitle"
                    value="#{nxu:test(contentView.translateTitle, messages[contentView.title], contentView.title)}" />
                  <h:outputText value="#{nxu:test(empty contentViewTitle, contentViewName, contentViewTitle)} " />
                  <br />

                  <c:if test="#{contentView.currentResultLayout.showCSVExport}">
                    <nxd:restDocumentLink document="#{currentDocument}"
                      view="xl" addTabInfo="false"
                      newConversation="true" target="_blank"
                      title="#{contentView.currentPageProvider.maxPageSize > 0 ? nxu:translate('label.contentview.export.xl.tooltip.maxSize', contentView.currentPageProvider.maxPageSize) : messages['label.contentview.export.xl.tooltip']}"
                      styleClass="tipsyShow">
                      <f:param name="contentViewName" value="#{contentView.name}" />
                      <f:param name="currentPage" value="0" />
                      <f:param name="pageSize" value="0" />
                      <h:graphicImage value="/icons/xls_export.png"
                        alt="#{messages['label.contentview.export.xl']}"
                        title="#{messages['label.contentview.export.xl']}" />
                      <h:outputText value=" #{messages['label.contentview.export.xl']}"/>
                    </nxd:restDocumentLink>
                    <br />
                  </c:if>

                </nxu:set>
                <br />

              </c:forEach>
              <br />
            </c:forEach>
          </c:if>
        </nxu:set>

      </div>

    </div>
  </ui:define>

</ui:composition>